import  {legacy_createStore  as  createStore , applyMiddleware}  from 'redux'

//能够根据是否为生产环境对redux中间件进行优化
// import  {composeWithDevTools }  from 'redux-devtools-extension'




import  rootReducer from './reducers'

import  thunk  from 'redux-thunk'

let middleWares;

console.log( 'env', process.env)
if(process.env.NODE_ENV==='production') {
 // 生产环境，只启用 thunk 中间件
 middleWares =applyMiddleware(thunk)
}else {
 // 开发环境
 const { composeWithDevTools } = require('redux-devtools-extension')
 middleWares = composeWithDevTools(applyMiddleware(thunk))

}

 

const  store=  createStore(rootReducer,middleWares)

export default  store

